package com.rdxer.api;

import com.rdxer.api.para.IdsStringListPara;
import com.rdxer.api.para.PaperAddQuestionPara;
import com.rdxer.core.entity.Result;
import com.rdxer.core.entity.StatusCode;
import com.rdxer.core.security.AppUserDetails;
import com.rdxer.core.utils.search.SearchPara;
import com.rdxer.dataview.PaperQuestionDV;
import com.rdxer.model.Course;
import com.rdxer.model.Paper;
import com.rdxer.service.CourseService;
import com.rdxer.service.PaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * departmentManagement
 */
@RestController
@CrossOrigin
@RequestMapping("/course")
public class CourseApi {

    @Autowired
    private CourseService service;

    /**
     * 查询本人的所有数据
     *
     */
    @GetMapping
    public Result<List<Course>> all() {
        return new Result<>(true, StatusCode.OK, "查询成功", service.findAllByUserId(AppUserDetails.getCurrent().account.getId()));
    }
    /**
     * 查询课程对应的 考试试卷
     *
     */
    @GetMapping("/{id}/paper")
    public Result<List<Paper>> findPaper(@PathVariable String id) {
        return new Result<>(true, StatusCode.OK, "查询成功", service.findAllPaperByCourseId(id));
    }
}
